﻿using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Text;

namespace T.FAS.Runtime.Metadata.Entity.DataModel
{
    public class TState : ICloneable
    {

        /// <summary>
        /// 主键id
        /// </summary>
        public string ID { get; set; }

        /// <summary>
        /// 所属状态机ID
        /// </summary>
        [JsonIgnore]
        public string StateMachineID { get; set; }

        /// <summary>
        /// 状态key，关联的SDO的列主键，应用于状态的SDO主键为int型
        /// </summary>
        public int Key { get; set; }

        /// <summary>
        /// 状态名称
        /// </summary>
        public string Name { get; set; }

        /// <summary>
        /// 状态描述
        /// </summary>
        public string Description { get; set; }

        /// <summary>
        /// False:正常状态，True:分组状态
        /// </summary>
        public bool IsGroup { get; set; }

        /// <summary>
        /// 父级状态id
        /// </summary>
        public string ParentID { get; set; }

        /// <summary>
        /// 排序
        /// </summary>
        public int Sort { get; set; }

        /// <summary>
        /// 限制规则
        /// </summary>
        public List<TRule> Rules{ get; set; }

        /// <summary>
        /// 备用字段
        /// </summary>
        [JsonIgnore]
        public string Ext1 { get; set; }

        /// <summary>
        /// 备用字段
        /// </summary>
        [JsonIgnore]
        public string Ext2 { get; set; }

        /// <summary>
        /// 备用字段
        /// </summary>
        [JsonIgnore]
        public string Ext3 { get; set; }

        /// <summary>
        /// 创建人
        /// </summary>
        [JsonIgnore]
        public string Creator { get; set; }

        /// <summary>
        /// 创建时间
        /// </summary>   
        [JsonIgnore]
        public DateTime CreateTime { get; set; }

        /// <summary>
        /// 最后修改人
        /// </summary>
        [JsonIgnore]
        public string LastModifier { get; set; }

        /// <summary>
        /// 最后修改时间
        /// </summary>    
        [JsonIgnore]
        public DateTime LastModifyTime { get; set; }

        public object Clone()
        {
            var newObject = this.MemberwiseClone() as TState;
            if (Rules != null)
            {
                newObject.Rules = new List<TRule>();
                this.Rules.ForEach(i => newObject.Rules.Add(i.Clone() as TRule));
            }
            return newObject;
        }
    }
}
